import requests

from common.config import getconf
from tests.new_rypark_background.get_cookie import internal_token


class ParkingGateDisPlayConfig:
    # =====================车道硬件配置管理=====================

    def update_led_display_config(self, env, type=1):
        """创建车道"""
        base_url = getconf(env, "zhongtai_url")
        url = base_url + "platform-parking-server/parkingGate/saveDisplayConfig"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "token": internal_token(env)}
        #LED-闲置
        {
            "configList": [
                {
                    "displayDictId": 3,
                    "displayLine": 1,
                    "displayName": "剩余车位"
                },
                {
                    "displayDictId": 0,
                    "displayLine": 2,
                    "displayName": ""
                },
                {
                    "displayDictId": 1,
                    "displayLine": 3,
                    "displayName": "系统日期"
                },
                {
                    "displayDictId": 2,
                    "displayLine": 4,
                    "displayName": "系统时间"
                }
            ],
            "displayType": 1,
            "eventType": 3,
            "parkingGateId": "72"
        }
        # LED-出场
        {
            "configList": [
                {
                    "displayDictId": 10,
                    "displayLine": 1,
                    "displayName": "车牌号码"
                },
                {
                    "displayDictId": 11,
                    "displayLine": 2,
                    "displayName": "车辆类型"
                },
                {
                    "displayDictId": 14,
                    "displayLine": 3,
                    "displayName": "停车时长"
                },
                {
                    "displayDictId": 15,
                    "displayLine": 4,
                    "displayName": "停车费用"
                }
            ],
            "displayType": 1,
            "eventType": "2",
            "parkingGateId": "72"
        }
        # 语音-识别车辆后播报内容（支持多选）+开闸放行播报内容（支持单选）
        {
            "configList": [
                {
                    "displayDictId": 23,
                    "displayName": "车牌号码"
                },
                {
                    "displayDictId": 24,
                    "displayName": "车辆类型"
                },
                {
                    "displayDictId": 25,
                    "displayName": "停车费用"
                },
                {
                    "displayDictId": 26,
                    "displayName": "停车时长"
                },
                {
                    "displayDictId": 27,
                    "displayName": "出场时间"
                },
                {
                    "displayDictId": 28,
                    "displayName": "请通行"
                }
            ],
            "displayType": 2,
            "eventType": 2,
            "parkingGateId": "72"
        }


        return requests.post(url, headers=headers, json=dict).json()

